package com.ruihui.activity.exceprion;

import org.slf4j.Logger;

import com.ruihui.activity.util.Result;
import com.ruihui.activity.util.ResultCode;

/**
 * 异常抓起处理类
 * 
 * @author cf
 * ManualException 自定义异常
 * IllegalArgumentException argument异常
 */
public class GetException {
	public static Object getCatch(Exception e, Logger log) {
		log.error(e.getMessage());
		if (e instanceof ManualException) {
			ManualException me = (ManualException) e;
			return new Result(me.getCode(), me.getMessage());
		} else if (e instanceof IllegalArgumentException) {
			return Result.errorMsg(e.getMessage());
		}
		return Result.failure(ResultCode.SYSTEM_INNER_ERROR);
	}

}
